

import util.JDBCHelper;

import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * @author ：xx
 * @date ：Created in 2020/3/26 17:39
 * @description：
 * @modified By：
 */
public class MemberDao {
    //存储完成之后的反馈

    public static Member login(String user, String pwd){
        Member member=null;
        try {
            ResultSet rs= JDBCHelper.query("select * from member where username=? and pwd=?",user,pwd);
            if(rs!=null&&rs.next())
            {
                member=new Member();
                member.setId(rs.getInt("id"));
                member.setUsername(rs.getString("user"));
                member.setName(rs.getString("name"));
                member.setSex(rs.getString("sex"));
                member.setAge(rs.getInt("age"));
                member.setEmail(rs.getString("email"));
                member.setPwd(rs.getString("pwd"));
                member.setLogintime(rs.getTimestamp("logintime"));
                System.out.println("当前用户："+member);
            }
        } catch (SQLException e) {
            System.out.println("登录出错"+e.getMessage());
        } finally {
            JDBCHelper.close();
        }
        return member;
    }


}
